Skip to content

[wasm2c] Add the very beginning of a wasm2c implementation and test harness#8763

Draft
lexi-nadia wants to merge 8 commits into
WebAssembly:mainfrom
lexi-nadia:main
Draft

[wasm2c] Add the very beginning of a wasm2c implementation and test harness#8763
lexi-nadia wants to merge 8 commits into
WebAssembly:mainfrom
lexi-nadia:main

Conversation

@lexi-nadia
Copy link
Copy Markdown

This change adds an extremely bare-bones wasm2c implementation and test harness.

Most of the code here is imported directly from WABT, particularly the boilerplate code and tests. The only substantive new code is in src/wasm2c.h, src/tools/wasm2c.cpp, and scripts/test/wasm2c.py.

I tried to prune this down to be as minimal as possible while still providing a useful checkpoint, but I'm not sure I succeeded. Please feel free to offer suggestions if you see more ways to shrink this down.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use .cpp instead of .cc as the extension for C++ sources.

//
// Result:
// A pointer for an object of size n.
#if WABT_BIG_ENDIAN
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to change uses of WABT to WASM2C or something like that.

Comment on lines +23 to +25
// We can only use Segue for this module if it uses a single unshared imported
// or exported memory
#if WASM_RT_USE_SEGUE && IS_SINGLE_UNSHARED_MEMORY
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will the testing story look like for all these different build configurations? I don't know what SEGUE is or who might be depending on it or how we're going to keep from breaking them.

Comment thread src/tools/CMakeLists.txt
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create a src/tools/wasm2c directory and move the prebuilt/ and templates/ there, along with all of this wasm2c-specific CMake stuff?

Comment thread src/tools/wasm2c.cpp
#include "support/file.h"

using namespace wasm;
using namespace wasm::WATParser;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we only have using namespace wasm; and use its child namespaces as part of the names in the code. So it would be WATParser::parseScript below.

Comment thread test/wasm2c/add.txt
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these text files used from? I didn't see anything in test/wasm2c.py, but maybe I missed it. It looks like they are similar to lit tests?

Comment thread third_party/picosha2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for? Is it just a benchmark?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How important is it to check in benchmarks? Is this something that can be added as a git submodule?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to avoid checking in this binary if we can avoid it.

Comment thread wasm2c/README.md
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to avoid adding a top-level wasm2c directory as well. Maybe this can move to tools/wasm2c along with the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants